home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / langguid / chap_06 / xmpl_05.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  650 b   |  35 lines  |  [TEXT/ttxt]

  1. --<<<
  2. -- Kaleida Labs, Inc.
  3. -- Field Guide to the ScriptX Language
  4. -- chapter 6, example 5
  5.  
  6. -- examples of defining methods
  7.  
  8. object myObj (RootObject)
  9.     inst vars a:500
  10.     inst methods
  11.     method incrementA self inc -> (
  12.         self.a := self.a + inc
  13.     )
  14. end
  15.  
  16. class GenericClass (RootObject)
  17.     instance methods
  18.     method printClass self -> (
  19.         print ("I'm an instance of " + (getClassName self))
  20.     )
  21.     method printMe self -> (
  22.         format debug "This is me: %*.\n" self @Normal 
  23.         printClass self
  24.     )
  25. end
  26.  
  27. class MyLL (Array)
  28.     instance methods
  29.     method addItemToBeginning self item -> (
  30.         addNth self 1 item
  31.         format debug "%* added" item @Normal
  32.         return self
  33.     )
  34. end
  35. -->>>